//
//  DownLoadImageCollectionViewCell.m
//  WuliHanhan
//
//  Created by tang on 16/3/9.
//  Copyright © 2016年 LVpeng. All rights reserved.
//

#import "DownLoadImageCollectionViewCell.h"


@interface DownLoadImageCollectionViewCell ()
{
    UIImageView *photoImageView;
    UIButton *selectButton;
    UIImageView *selectImage;
    
}
@end


@implementation DownLoadImageCollectionViewCell



- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self initUI];
    }
    return self;
}


- (void)initUI
{
    [self setBackgroundColor:[UIColor yellowColor]];
    photoImageView = [[UIImageView alloc] initWithFrame:self.bounds];
    [self addSubview:photoImageView];
    
    selectImage = [[UIImageView alloc] initWithFrame:self.bounds];
    [self addSubview:selectImage];
    
    
    selectButton = [[UIButton alloc] initWithFrame:self.bounds];
    [self addSubview:selectButton];
    [selectButton addTarget:self action:@selector(selectImage:) forControlEvents:UIControlEventTouchUpInside];
    
}


//设置图片
- (void)setDataImage:(UIImage *)dataImage
{
    [photoImageView setImage:dataImage];
}



//选择图片
- (void)selectImage:(UIButton *)sender
{
    if ([selectButton isSelected])
    {
        //取消选中
        //        [selectImage setImage:[UIImage imageNamed:@""]];
        [selectImage setBackgroundColor:[UIColor clearColor]];
        [selectButton setSelected:NO];
    }
    else
    {
        //选中图片
        [selectImage setImage:[UIImage imageNamed:@""]];
        [selectImage setBackgroundColor:[UIColor redColor]];
        [selectButton setSelected:YES];
    }
}

@end
